-
Notifications
You must be signed in to change notification settings - Fork 187
Nexus caller timeouts #2760
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Nexus caller timeouts #2760
Conversation
|
Can we add some tests like we have for activity sdk-java/temporal-sdk/src/test/java/io/temporal/workflow/activityTests/ActivityTimeoutTest.java Line 51 in 2322bd0
|
We have coverage in NexusWorkflowTest.java. |
| Assert.assertTrue("OPERATION_TIMEOUT should be positive", operationTimeoutMs > 0); | ||
|
|
||
| // Sleep longer than schedule-to-start timeout to trigger the timeout | ||
| Thread.sleep(2000); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be able to use testWorkflowRule.sleep here to avoid waiting real time in the time skipping test server, but I would prefer the test not use a sleep and just wait for the condition to be true. Should be possible to wait for the operation to fail by looking at the workflow describe output no?
NexusWorkflowTest.java doesn't use the Java SDK so it is not providing coverage of the SDK |
|
you also need to update |
maciejdudko
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I left a few comments about timeout calculation in test server but otherwise looks good.
| long elapsedSeconds = Timestamps.between(scheduledTime, currentTime).getSeconds(); | ||
| long elapsedMillis = elapsedSeconds * 1000; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This rounds off milliseconds from the difference. At the extreme, a sub-second timeout will be rounded to zero.
| long elapsedSeconds = Timestamps.between(scheduledTime, currentTime).getSeconds(); | |
| long elapsedMillis = elapsedSeconds * 1000; | |
| long elapsedMillis = com.google.protobuf.util.Durations.toMillis( | |
| Timestamps.between(scheduledTime, currentTime)); |
| // Calculate minimum of all applicable timeouts | ||
| Long remainingMillis = null; | ||
|
|
||
| if (!isStarted && scheduledEvent.hasScheduleToStartTimeout()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ScheduleToStartTimeout should not be part of the calculation here.
| com.google.protobuf.util.Durations.toMillis( | ||
| scheduledEvent.getScheduleToCloseTimeout()); | ||
| if (scheduleToCloseMillis > 0) { | ||
| long remaining = scheduleToCloseMillis - elapsedMillis; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This code should handle the situation where elapsedMillis is larger than scheduleToCloseMillis for some reason, just for extra safety.
| long remaining = scheduleToCloseMillis - elapsedMillis; | |
| long remaining = Math.max(1, scheduleToCloseMillis - elapsedMillis); |
| long remaining = startToCloseMillis - elapsedMillis; | ||
| remainingMillis = | ||
| (remainingMillis == null) ? remaining : Math.min(remainingMillis, remaining); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
StartToCloseTimeout should not have elapsed time subtracted.
| long remaining = startToCloseMillis - elapsedMillis; | |
| remainingMillis = | |
| (remainingMillis == null) ? remaining : Math.min(remainingMillis, remaining); | |
| remainingMillis = | |
| (remainingMillis == null) ? startToCloseMillis : Math.min(remainingMillis, startToCloseMillis); |
What was changed
ScheduleToStartTimeoutandStartToCloseTimeoutfor Nexus operations in the Java SDK and test server.timeoutNexusOperation()pollNexusTaskQueue()and use the correct header formatNOTE: Do not merge until the API is tagged.